package cn.jiyun.dao;

import cn.jiyun.pojo.Order;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.Map;

public interface OrderDao {

    @Select("SELECT * FROM t_order WHERE member_id = #{memberId} and orderDate = #{orderDate} and setmeal_id = #{setmealId}")
    Order find(Map<String, Object> map);

    void add(Order order);

    @Select("SELECT m.name as member,o.orderDate,o.orderType,s.`name` as setmeal FROM t_order o,t_member m,t_setmeal s WHERE o.member_id = m.id and o.setmeal_id = s.id and o.id = #{id}")
    Map<String, Object> findById(Integer id);

    @Select("SELECT count(*) from t_order where orderDate = #{todayStr}")
    Integer getTodayOrderNumber(String todayStr);

    @Select("SELECT count(*) from t_order where orderDate = #{todayStr} and orderStatus ='已到诊'")
    Integer getTodayVisitsNumber(String todayStr);

    @Select("SELECT count(*) from t_order where orderDate >= #{firstDayOfWeek} and orderDate <= #{lastDayOfWeek}")
    Integer getThisWeekOrderNumber(Date firstDayOfWeek,Date lastDayOfWeek);

    @Select("SELECT count(*) from t_order where orderDate >= #{firstDayOfWeek} and orderDate <= #{lastDayOfWeek} and orderStatus ='已到诊' ")
    Integer getThisWeekVisitsNumber(Date firstDayOfWeek,Date lastDayOfWeek);
}
